#include "AttackFleet.hh"

using namespace Geom;
using namespace World;

Fleet::AttackFleet::AttackFleet(spFleet target):
    target(target) {}

bool Fleet::AttackFleet::execute(spFleet fleet) {
    spFleet _target = target.toStrongRef();

    // A célpont megszűnt
    if (_target.isNull())
        return true;

    Vector<> dest = _target->get_position();
    fleet->move_towards(dest);

    // Még túl messze vagyunk
    if ((fleet->position - dest).get_length() >= 0.05)
        return false;

    // Odaértünk
    _target->attack(fleet);
    return true;
}
